package g4.map;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.graphics.drawable.Drawable;



public class MySpinnerAdapter extends ArrayAdapter<String>{

	private Context context;
	private String[] names;
	private Drawable[] icons;
	
public MySpinnerAdapter(Context context, int textViewResourceId, String[] objects, Drawable[] Icons) {
super(context, textViewResourceId, objects);
this.names = objects;
this.icons = Icons;
// TODO Auto-generated constructor stub
}

@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
// TODO Auto-generated method stub
return getCustomView(position, convertView, parent);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
return getCustomView(position, convertView, parent);
}

public View getCustomView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);

	System.out.println("lawl");
	
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(context.LAYOUT_INFLATER_SERVICE);
 	
System.out.println("lawl2");

View row=inflater.inflate(R.layout.rowlayout, parent, false);
TextView label=(TextView)row.findViewById(R.id.label2);

System.out.println("lawl3");
System.out.println("names pos" + position);
System.out.println("names pos" + names[position]);

if(label!=null){
label.setText(names[position]);
}

ImageView icon=(ImageView)row.findViewById(R.id.icon);
icon.setImageDrawable(icons[position]);
System.out.println("lawl5");



return row;
}
}